createOrNull

Builds picture in picture for canvas, or answers null when this browser has neither feature, or when canvas is not an element of a page (an OffscreenCanvas is not).

Parameters

canvas

the HTMLCanvasElement that renderer draws into.

renderer

told the window's size while the canvas is in the document window, and the page's size again when it comes back.

player

played and paused by the buttons of the video element's window.


fun createOrNull(canvas: JsAny, setViewport: (width: Int, height: Int, scale: Float) -> Unit, play: () -> Unit, pause: () -> Unit): KitePlayerPictureInPicture?

Builds picture in picture for a canvas that is drawn from somewhere else, such as the page's canvas of a worker player, whose drawing was handed to the worker; or answers null as the other overload does. KitePlayerWorker.pictureInPictureOrNull calls this.

Both features carry a canvas drawn from a worker. Measured in Chromium 141, headless and on a display: the canvas moved into the document window keeps showing each new frame, and a live capture of it plays in the video element's window.

Parameters

canvas

the HTMLCanvasElement on the page.

setViewport

sizes the canvas's drawing buffer, as VideoRenderer.setViewport does: to the window's size while the canvas is in the document window, and back after.

play

called by the play button of the video element's window.

pause

called by the pause button of the video element's window.